package com.feihao.zhou.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class AOPAdvice {
    /*public void function(){
        System.out.println("共性方法  before！！");
    }

    public void after(){
        System.out.println("共性方法  after！！");
    }

    public void afterReturning(){
        System.out.println("共性方法  afterReturning！！");
    }

    public void afterThrowing(){
        System.out.println("共性方法  afterThrowIng！！");
    }
    public void around(ProceedingJoinPoint pjp){
        //调用原始方法：
        try {
            System.out.println("共性方法  before！！");
            pjp.proceed();
            System.out.println("afterReturning ");
        } catch (Throwable throwable) {
            System.out.println("afterThrowing");
            throwable.printStackTrace();
        }finally {
            System.out.println("after");
        }

    }*/


    public void before(JoinPoint jp){
        Object[] args = jp.getArgs();
        System.out.println("before共性功能："+args[0]);
    }
    public void after(){
        System.out.println("共性方法  after！！");
    }

    public void afterReturning(){
        System.out.println("共性方法  afterReturning！！");
    }

    public void afterThrowing(){
        System.out.println("共性方法  afterThrowIng！！");
    }
    public void around(ProceedingJoinPoint pjp){
        //调用原始方法：
        try {
            System.out.println("共性方法  before！！");
            pjp.proceed();
            System.out.println("afterReturning ");
        } catch (Throwable throwable) {
            System.out.println("afterThrowing");
            throwable.printStackTrace();
        }finally {
            System.out.println("after");
        }

    }
}

